﻿@page "/datagrid/sorting-api"

@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.DropDowns
@using BlazorDemos
@using blazor_griddata
@inherits SampleBaseComponent;


<div class="col-lg-12 control-section">
    <div class="content-wrapper">
        <div class="row">
            <SfGrid DataSource="@GridData"  AllowSorting="true" AllowPaging="true">
                <GridPageSettings PageCount="2"></GridPageSettings>
                <GridColumns>
                    <GridColumn Field=@nameof(OrdersDetails.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.CustomerID) HeaderText="Customer ID" Width="150"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
                    <GridColumn Field=@nameof(OrdersDetails.ShipCountry) HeaderText="Ship Country" Width="150"></GridColumn>
                </GridColumns>
            </SfGrid>

        </div>
    </div>
</div>



@code{

    public List<OrdersDetails> GridData { get; set; }

    public class ColumnNames
    {
        public string id { get; set; }

        public string name { get; set; }
    }

    public class Direction
    {
        public string id { get; set; }

        public string name { get; set; }
    }

    private List<ColumnNames> names = new List<ColumnNames>()
{
        new ColumnNames(){ id= "OrderID", name= "Order ID" },
        new ColumnNames(){ id= "CustomerID", name= "Customer ID" },
        new ColumnNames(){ id= "OrderDate", name= "Order Date" },
        new ColumnNames(){ id= "Freight", name= "Freight" },
        new ColumnNames(){ id= "ShipCountry", name= "Ship Country" },
    };

    private List<Direction> direction = new List<Direction>()
{
        new Direction(){ id= "Ascending", name= "Ascending" },
        new Direction(){ id= "Descending", name= "Descending" },
    };

    protected override void OnInitialized()
    {
        GridData = OrdersDetails.GetAllRecords();
    }
}
